package enumDemo;
//不可被继承，无法拓展
public enum  TestEnum {
    RED("RED",0),
    BLACK("BLACK",1),
    YELLOW("YELLOW",2);
    //枚举类的构造方法是私有的！
    private  String color;
    private  int ordinal;

    TestEnum(String color, int ordinal) {
        this.color = color;
        this.ordinal = ordinal;
    }

    public static void main(String[] args) {
        TestEnum[] testEnums=TestEnum.values();
        for (int i = 0; i < testEnums.length; i++) {
            System.out.println(testEnums[i]+" "+testEnums[i].ordinal());
        }
        //字符串变成枚举成员
        TestEnum testEnum=TestEnum.valueOf("RED");
        System.out.println(testEnum);
        System.out.println(RED.compareTo(YELLOW));
    }
    public static void main1(String[] args) {
        TestEnum testEnum = TestEnum.RED;
        switch (testEnum){
            case RED:
                System.out.println("红色");
                break;
            case BLACK:
                System.out.println("黑色");
                break;
            case YELLOW:
                System.out.println("黄色");
                break;
        }

    }
}
